import suds, time
workqueue = suds.client.Client('http://ec2-184-73-196-191.compute-1.amazonaws.com:9540/workqueue?wsdl')
crashes = suds.client.Client('http://ec2-184-73-196-191.compute-1.amazonaws.com:9540/crashes?wsdl')
a = 0
b = 0
average = 0
f = open('/home/arthurkok/soap_stats2.cvs', 'a')
f.write('Number of Elements,Average,Pending\n')
f.close()	
while True:	
	size = workqueue.service.getSize().number_of_elements
	print "Size of Work Queue:\t" + repr(size)
	pending = len(workqueue.service.getPendingPackets())
	print "Size of Pending Queue:\t" + repr(pending)
	a = crashes.service.getCrashedUrlsSize()
	print "Number of dumped URLS:\t" + repr(a)
	average = (a-b+average)/2
	print "2.5 Sec Avg Urls Dumped:\t" + repr(average)
	if (pending != 0):
		f = open('/home/arthurkok/soap_stats.cvs', 'a')
		f.write(repr(size) + ',' + repr(average) + ',' + repr(a) + '\n')
		f.close()	
	b = a
	print ''
	time.sleep(2.5)

